package com.androidx.p013lv.base.adapter;

import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.androidx.p013lv.base.C1010R;
import com.androidx.p013lv.base.bean.OfficialBean;
import com.androidx.p013lv.base.glide.GlideUtils;
import com.androidx.p013lv.base.recycler.BaseRecyclerAdapter;
import com.androidx.p013lv.base.recycler.BaseRecyclerHolder;
import com.androidx.p013lv.base.utils.UiUtils;
import com.androidx.p013lv.base.view.LabelView;
import com.bumptech.glide.Glide;

/* renamed from: com.androidx.lv.base.adapter.SquareAdapter */
public class SquareAdapter extends BaseRecyclerAdapter<OfficialBean, Holder> {
    String domain;
    boolean isAttention;

    public SquareAdapter(boolean z) {
        this.isAttention = z;
    }

    public String getDomain() {
        return this.domain;
    }

    public void setDomain(String str) {
        this.domain = str;
    }

    public void MyHolder(Holder holder, int i) {
        holder.setData((OfficialBean) getDataInPosition(i), i);
    }

    public void onViewRecycled(Holder holder) {
        super.onViewRecycled((RecyclerView.ViewHolder) holder);
        ImageView imageView = holder.iv_cover;
        if (imageView != null) {
            Glide.with(imageView.getContext()).clear(imageView);
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.Adapter
    public Holder onCreateViewHolder(ViewGroup viewGroup, int i) {
        return new Holder(LayoutInflater.from(viewGroup.getContext()).inflate(C1010R.C1015layout.item_square, viewGroup, false));
    }

    /* access modifiers changed from: package-private */
    /* renamed from: com.androidx.lv.base.adapter.SquareAdapter$Holder */
    public class Holder extends BaseRecyclerHolder {
        ImageView iv_cover;
        ImageView iv_man_girl;
        LinearLayout ll_content;
        LinearLayout ll_label;
        TextView tv_address;
        TextView tv_name;
        TextView tv_num;

        private Holder(View view) {
            super(view);
            this.ll_content = (LinearLayout) view.findViewById(C1010R.C1013id.ll_content);
            this.ll_label = (LinearLayout) view.findViewById(C1010R.C1013id.ll_label);
            this.iv_cover = (ImageView) view.findViewById(C1010R.C1013id.iv_cover);
            this.tv_name = (TextView) view.findViewById(C1010R.C1013id.tv_name);
            this.tv_address = (TextView) view.findViewById(C1010R.C1013id.tv_address);
            this.tv_num = (TextView) view.findViewById(C1010R.C1013id.tv_num);
            this.iv_man_girl = (ImageView) view.findViewById(C1010R.C1013id.iv_man_girl);
        }

        public void setData(OfficialBean officialBean, int i) {
            LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) this.ll_content.getLayoutParams();
            if (i == 0) {
                layoutParams.topMargin = UiUtils.dp2px(4);
            } else {
                layoutParams.topMargin = UiUtils.dp2px(11);
            }
            this.ll_content.setLayoutParams(layoutParams);
            if (SquareAdapter.this.isAttention) {
                GlideUtils.loadCropRadius(SquareAdapter.this.domain + officialBean.getLogo(), 4, this.iv_cover);
                this.tv_num.setVisibility(8);
            } else {
                GlideUtils.loadCropRadius(SquareAdapter.this.domain + officialBean.getSquareImg(), 4, this.iv_cover);
                this.tv_num.setVisibility(0);
                TextView textView = this.tv_num;
                textView.setText(officialBean.getWatchNum() + "人看過");
            }
            this.tv_name.setText(officialBean.getNickName());
            if (TextUtils.isEmpty(officialBean.getCityName())) {
                this.tv_address.setText("小草星");
            } else {
                TextView textView2 = this.tv_address;
                textView2.setText(officialBean.getProvinceName() + "·" + officialBean.getCityName());
            }
            this.ll_label.removeAllViews();
            if (officialBean.getUserTags() != null) {
                for (int i2 = 0; i2 < officialBean.getUserTags().size(); i2++) {
                    this.ll_label.addView(new LabelView(this.ll_label.getContext(), officialBean.getUserTags().get(i2)));
                    if (i2 == 2) {
                        break;
                    }
                }
            }
            if (officialBean.getGender() == 1) {
                this.iv_man_girl.setImageResource(C1010R.C1012drawable.ic_girl);
            } else if (officialBean.getGender() == 2) {
                this.iv_man_girl.setImageResource(C1010R.C1012drawable.ic_man);
            } else {
                this.iv_man_girl.setImageResource(C1010R.C1012drawable.ic_man_girl);
            }
        }
    }
}
